//
//  CaseView.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/15.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "CaseView.h"
#import "DocumentListViewController.h"
#import "PersonalityListViewController.h"
#import "LayListViewController.h"
#import "CaseEntrustListViewController.h"

@implementation CaseView
-(void)creatView{
    
    UIScrollView *scrollView=[UIScrollView new];
    [self addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    scrollView.scrollsToTop =NO;
    
    scrollView.showsVerticalScrollIndicator = FALSE;
    scrollView.showsHorizontalScrollIndicator = FALSE;
    scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    scrollView.contentSize = CGSizeMake(0,600);
    
    
    
    self.backgroundColor=_LightGrey;
    UIView *topView=[UIView new];
    [scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(_mainW-20);
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(NAV_HEIGHT+15);
        make.height.mas_equalTo(200);
    }];
    topView.layer.cornerRadius=4;
    topView.backgroundColor=[UIColor whiteColor];
    
    UIView *layView=[UIView new];
    [topView addSubview:layView];
    [layView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(_mainW/2-10);
    }];
    layView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToLayListView:)];
    [layView addGestureRecognizer:tapGesture];
    
    UIImageView *layImage=[UIImageView new];
    [layView addSubview:layImage];
    [layImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.width.height.mas_equalTo(60);
    }];
    layImage.image=[UIImage imageNamed:@"法律咨询"];
    
    UILabel *label1=[UILabel new];
    [layView addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(layImage.mas_bottom).mas_equalTo(10);
    }];
    label1.text=@"法律咨询";
    label1.textColor=ColorWithRGB(100, 100, 100);
    label1.font=[UIFont systemFontOfSize:22];
    
    UIView *caseView=[UIView new];
    [topView addSubview:caseView];
    [caseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(_mainW/2-10);
    }];
    caseView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToCaseListView:)];
    [caseView addGestureRecognizer:tapGesture2];
    
    
    UIImageView *caseImage=[UIImageView new];
    [caseView addSubview:caseImage];
    [caseImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.width.height.mas_equalTo(60);
    }];
    caseImage.image=[UIImage imageNamed:@"法律咨询"];
    
    UILabel *label2=[UILabel new];
    [caseView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(caseImage.mas_bottom).mas_equalTo(10);
    }];
    label2.text=@"我的案件";
    label2.textColor=ColorWithRGB(100, 100, 100);
    label2.font=[UIFont systemFontOfSize:22];
    
    

    
    UIView *bottomView=[UIView new];
    [scrollView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(20);
    }];
    bottomView.backgroundColor=[UIColor whiteColor];
    bottomView.layer.cornerRadius=4;
    
    
    UIView *documentView=[UIView new];
    [bottomView addSubview:documentView];
    [documentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(_mainW/2-10);
    }];
    documentView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToDocumentView:)];
    [documentView addGestureRecognizer:tapGesture3];
    
    UIImageView *documentImage=[UIImageView new];
    [documentView addSubview:documentImage];
    [documentImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.width.height.mas_equalTo(60);
    }];
    documentImage.image=[UIImage imageNamed:@"代写文书1"];
    
    UILabel *label3=[UILabel new];
    [documentView addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(documentImage.mas_bottom).mas_equalTo(10);
    }];
    label3.text=@"代写文书";
    label3.textColor=ColorWithRGB(100, 100, 100);
    label3.font=[UIFont systemFontOfSize:22];
    
    
    UIView *personalityView=[UIView new];
    [bottomView addSubview:personalityView];
    [personalityView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(_mainW/2-10);
    }];
    
    personalityView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToPersonalityView:)];
    [personalityView addGestureRecognizer:tapGesture4];
    
    UIImageView *personalityImage=[UIImageView new];
    [personalityView addSubview:personalityImage];
    [personalityImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.width.height.mas_equalTo(60);
    }];
    personalityImage.image=[UIImage imageNamed:@"个性服务1"];
    
    UILabel *label4=[UILabel new];
    [personalityView addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(personalityImage.mas_bottom).mas_equalTo(10);
    }];
    label4.text=@"个性服务";
    label4.textColor=ColorWithRGB(100, 100, 100);
    label4.font=[UIFont systemFontOfSize:22];
    
    UIImageView *imaView=[UIImageView new];
    [scrollView addSubview:imaView];
    [imaView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(50);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo(30);
    }];
    imaView.image=[UIImage imageNamed:@"纽带"];
    
    UIImageView *imaView2=[UIImageView new];
    [scrollView addSubview:imaView2];
    [imaView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(topView).mas_equalTo(-40);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo(30);
    }];
    imaView2.image=[UIImage imageNamed:@"纽带"];
}

-(void)pushToDocumentView:(UITapGestureRecognizer *)tap{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    if (userDic==nil) {
        [ZQTools ToLoging:self.viewController];
        return;
    }
    else{
        DocumentListViewController *releaseCase=[[DocumentListViewController alloc] init];
        [ZQTools pushNextViewController:self.viewController andRootController:releaseCase];
    }
}
-(void)pushToPersonalityView:(UITapGestureRecognizer *)tap{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    if (userDic==nil) {
        [ZQTools ToLoging:self.viewController];
        return;
    }
    else{
        PersonalityListViewController *releaseCase=[[PersonalityListViewController alloc] init];
        [ZQTools pushNextViewController:self.viewController andRootController:releaseCase];
    }
}

-(void)pushToLayListView:(UITapGestureRecognizer *)tap{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    if (userDic==nil) {
        [ZQTools ToLoging:self.viewController];
        return;
    }
    else{
        LayListViewController *releaseCase=[[LayListViewController alloc] init];
        [ZQTools pushNextViewController:self.viewController andRootController:releaseCase];
    }
}
-(void)pushToCaseListView:(UITapGestureRecognizer *)tap{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    if (userDic==nil) {
        [ZQTools ToLoging:self.viewController];
        return;
    }
    else{
        CaseEntrustListViewController *releaseCase=[[CaseEntrustListViewController alloc] init];
        [ZQTools pushNextViewController:self.viewController andRootController:releaseCase];
    }
}

@end
